package com.example.ssm1.controller;

import com.example.ssm1.exception.BusinessException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;


@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(value = {BusinessException.class})
    public String handlerException(BusinessException e, HttpServletRequest request, Model model) {
        System.out.println(e.getMessage());
        model.addAttribute("msg",e.getMessage());
        return "error";
    }
}
